package casa.depesos.app.com.http.req;

import casa.depesos.app.com.http.HttpReq;
import casa.depesos.app.com.http.Req;
import casa.depesos.app.com.http.ReqCallback;
import casa.depesos.app.com.http.bean.CardInfoBean;
import casa.depesos.app.com.http.bean.WhiteDataBean;
import casa.depesos.app.com.http.parser.CardInfoParser;
import casa.depesos.app.com.utils.Constant;

public class CardInfoReq implements HttpReq<CardInfoBean> {

    boolean isMe;

    public CardInfoReq(boolean isMe) {
        this.isMe = isMe;
    }

    @Override
    public void req(ReqCallback<CardInfoBean> callback) {//   /app/cust/queryIdCardInfo
        if (Constant.white) {
            new GetWhiteReq().req(new ReqCallback<WhiteDataBean>() {
                @Override
                public void callback(boolean success, WhiteDataBean bean) {
                    if (success && bean.isValid()) {
                        CardInfoBean tmp = new CardInfoBean();
                        tmp.card = bean.getData().card;
                        callback.callback(true, tmp);
                    } else {
                        callback.callback(false, null);
                    }
                }
            });
        } else {
            String url = isMe ? "/app/professionalData/retrieveIdentificationDocumentInfo" : "/app/ocrAndBiometric/retrieveIdentificationCardInfo";
            Req.post(url, getParam(), getHeader(), getBody(), new CardInfoParser(), callback, this);
        }
    }
}
